<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>测试删除接口</title>
</head>
<body>
<h2>测试删除房屋接口：DELETE /house/batch</h2>
<label>输入要删除的ID（多个用逗号分隔）：</label>
<input type="text" id="ids" value="1,2,3" />
<br><br>
<button onclick="sendDelete()">发送删除请求</button>

<pre id="result" style="background:#f4f4f4;padding:10px;"></pre>

<script>
    function sendDelete() {
        const ids = document.getElementById("ids").value
            .split(",")
            .map(id => parseInt(id.trim()))
            .filter(id => !isNaN(id));

        fetch("http://localhost:8001/myboot/house/batch", {
            method: "DELETE",
            headers: {
                "Content-Type": "application/json"
            },
            body: JSON.stringify(ids)
        })
            .then(res => {
                document.getElementById("result").innerText =
                    `状态码：${res.status}\n返回内容：${res.statusText}`;
                return res.text();
            })
            .then(text => {
                document.getElementById("result").innerText += `\n${text}`;
            })
            .catch(err => {
                document.getElementById("result").innerText = "请求失败：" + err;
            });
    }
</script>
</body>
</html>